package mn.idax.exchange.otc.config;

import mn.idax.exchange.otc.constant.RequestUrlConstant;
import org.atmosphere.cpr.AtmosphereServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import sun.misc.Request;

/**
 * @Auther: dison
 * @Date: 2018/8/30 09:58
 * @Description:
 */
@Configuration
public class AtmosphereConfig {

    @Bean
    public ServletRegistrationBean servletRegistrationBean() {
        ServletRegistrationBean servletBean = new ServletRegistrationBean(new AtmosphereServlet(), RequestUrlConstant.NOTIFY_INTERCEPT_PATH);
        servletBean.addInitParameter("org.atmosphere.cpr.packages", "mn.idax.exchange.otc.*");
        // 心跳间隔时间
        servletBean.addInitParameter("org.atmosphere.interceptor.HeartbeatInterceptor.clientHeartbeatFrequencyInSeconds", "5");
        servletBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return servletBean;
    }


}
